package com.minyifang.wcspf.work.ui.user.activities;

import android.content.Intent;
import android.net.Uri;
import android.widget.TextView;

import com.minyifang.wcspf.R;
import com.minyifang.wcspf.common.base.BaseMvpActivity;
import com.minyifang.wcspf.common.utils.ToastHelper;
import com.minyifang.wcspf.work.ui.user.model.ServiceBean;
import com.minyifang.wcspf.work.ui.user.presenter.ServicePresenter;
import com.minyifang.wcspf.work.ui.user.view.ServiceView;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 联系客服
 */
public class ServiceActivity extends BaseMvpActivity<ServiceView, ServicePresenter> implements ServiceView {

    @BindView(R.id.tv_tel)
    TextView mTvTel;
    @BindView(R.id.tv_workday)
    TextView mTvWorkDay;
    @BindView(R.id.tv_weekday)
    TextView mTvWeekDay;

    @Override
    protected int setContentLayoutRes() {
        return R.layout.activity_service;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        mPresenter.getData();
    }

    @Override
    protected ServicePresenter createPresenter() {
        return new ServicePresenter();
    }

    @OnClick(R.id.tv_tel)
    public void call() {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + mTvTel.getText().toString()));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }

    @Override
    public void showLoadingView() {
        showLoadingDialog();
    }

    @Override
    public void hideLoadingView() {
        hideLoadingDialog();
    }

    @Override
    public void onNetworkError() {
        hideLoadingView();
    }

    @Override
    public void showDataRes(ServiceBean data) {
        mTvTel.setText(data.getTel());
        mTvWorkDay.setText(String.format("周一至周五：%s", data.getServiceTime()));
        mTvWeekDay.setText(String.format("周六至周日：%s", data.getServiceTimeRest()));
    }

    @Override
    public void showRequestFailed(String message) {
        ToastHelper.getInstance(this).showWarn(message);
    }
}
